<?php
if ($page): 

#$node=_advert_get_node($node);
#pre($node);
$rec_napt=db_select('node_advert_private_types','napt')->fields('napt')->orderBy('name', 'ASC')->execute();
while($napt = $rec_napt->fetchAssoc()) 
 {
 #$napt_options[$napt['code']]=$napt['name']." (".$napt['price']." гр.)";
 $private_status[$napt['code']]=$napt['name'];
 } 
$breadcrumb=array();
if(isset($node->taxonomy))
foreach($node->taxonomy as $t)
{
$parents=taxonomy_get_parents_all($t);
if($parents[0]->vid==12){break;}
}
#pre($parents);
if(count($parents))
{
$parents=array_reverse($parents);
$c=count($parents);
$i=0;
foreach($parents as $p)
  {
  $breadcrumb[]=($i<$c)?l($p->name,'taxonomy/term/'.$p->tid):'<strong>'.$p->name.'</strong>';
  
  $i++;
  }
}
  if(count($node->advert['offers']))
  {
  $offers_rec=db_select("advert_offers","ao")->fields("ao")->condition('id',$node->advert['offers'],'IN')->execute();
  while($of=$offers_rec->fetchObject())
    {
    
    $offers[]=$of->name;
    }
  }
?>
<!--TABLE BORDER=1>
<TR>
<TD class="box_content"-->
<!--content bof-->
<!--div class="advert_fathorits_box">Избранные</div-->
<?=_advert_header_content_node();?>
<?php print implode("&nbsp;/&nbsp;",$breadcrumb);
if(isset($node->files)):
 
?>
<div style="float:right;margin-right:20px;" id="slider"><?

 

  #print '<div id="slider">';
  foreach($node->files as  $pic_file)
  {
  #$pic_file=array_shift($node->files);
  /*
  $variables= array(
		  'path' => $pic_file['uri'],
		  'alt' => $node->title,
		  'title' => $node->title,
		  'width' => '200',
		  'height' => '100%',
		   'attributes' => array('class' => 'some-img', 'id' => 'my-img'),
      );
  print theme_image($variables)."<br>";*/
  $options = array(
  'style_name' => 'advert',
  'alt' => 'Alternative Text',
  'path' => $pic_file['uri']
);

  echo theme('image_style', $options);
 # echo 'xxx';
  }
  #print "</div>";
  
?></div>
<script type="text/javascript">

jQuery(document.window). load (function () {
    $('slider'). NivoSlider ({
    keyboardNav: false,
	slices: 15,
	effect: 'sliceDown',
        animSpeed: 500,
        pauseTime: 3000,
        startSlide: 0, // Задаётся начало прокрутки  (0 index)
      directionNav: false, // Next & Prev navigation
      directionNavHide: false, // Only show on hover
      controlNav: true, // 1,2,3... navigation
       controlNavThumbs: true, // Use thumbnails for Control Nav
	pauseOnHover: true, // Stop animation while hovering
      manualAdvance: false // Force manual transitions
     
    });
    
 
});

</script>
<? endif;?>
<table border=0 width="90%"><tr>
<td>
<?

print '<h1 class="title">'.($offers?implode(",",$offers)." ":"").$node->title.'</h1>';
?></td><td align="right"><?
if(!empty($node->advert['field_price_from']) || !empty($node->advert['field_price_end']))
{
print "<p>";
print (!empty($node->advert['field_price_from'])?' Цена от <b>'.$node->advert['field_price_from']."</b>":"");
print (!empty($node->advert['field_price_end'])?' Цена до <b>'.$node->advert['field_price_end']."</b>":"");
print "</p>";
}
if(!empty($node->advert['field_price']))
{
if($node->advert['field_private_status']=='private')
  {
  print "<p>Цена: ".$node->advert['field_price']."</p>";
  }else{
  print "<p>Цена розничная: ".$node->advert['field_price']."</p>";
  }
}
if(!empty($node->advert['field_price_optom']))
{
print "<p>Цена оптовая: ".$node->advert['field_price_optom']."</p>";
}
?></td>
</tr>
<tr><td colspan=2>
<div class="content"<?php print $content_attributes; ?>>
    <?php
      // Hide comments, tags, and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      hide($content['field_tags']);
	  print $node->advert['body'];
      #print render($content);
    ?>
  </div></td></tr>
  <tr><td colspan=2>
  <?/*
  if(!empty($node->advert['field_price_from']) || !empty($node->advert['field_price_end']))
{
print "<p>";
print (!empty($node->advert['field_price_from'])?' Цена от <b>'.$node->advert['field_price_from']."</b>":"");
print (!empty($node->advert['field_price_end'])?' Цена до <b>'.$node->advert['field_price_end']."</b>":"");
print "</p>";
}

if(!empty($node->advert['field_price']))
{
if($node->advert['field_private_status']=='private')
  {
  print "<p>Цена: ".$node->advert['field_price']."</p>";
  }else{
  print "<p>Цена розничная: ".$node->advert['field_price']."</p>";
  }
}
if(!empty($node->advert['field_price_optom']))
{
print "<p>Цена оптовая: ".$node->advert['field_price_optom']."</p>";
}*/
  ?>
  </td></tr>
  <tr><td colspan=2>
  <?
  #pre($node->custom_fields);
  $custom_fields=advert_prepare_custom_fields_display($node->custom_fields);
#pre($custom_fields);
foreach($custom_fields as $field)
  {
  
  print "<p><strong>".$field->name.":</strong> ".$field->value->value_name."</p>";
  if($field->field=='car_brand')
    {
   print _advert_call_car_model_display($node->custom_fields);
    }
  
  //}
  }
  
  ?>
  </td></tr>
  <tr><td colspan=2>
  <?
  #print "<h5>обьявление ".$private_status[$node->advert['field_private_status']]."</h5>";
if(!empty($node->advert['personal_name']))
{
print '<p>Имя: <b>'.$node->advert['personal_name'].'</b></p>';
}
if(!empty($node->advert['bussiness_name']))
{
print '<p>Контактное лицо: <b>'.$node->advert['bussiness_name'].'</b></p>';
}
if(!empty($node->advert['company_name']))
{
print '<p>Название компании: <b>'.$node->advert['company_name'].'</b></p>';
}
if(count($node->custom_fields['field_phone']))
{
print "<p>Телефоны:<b>";
if(is_object($node->custom_fields['field_phone']))
{
print $node->custom_fields['field_phone']->value."&nbsp;";

}else{
foreach($node->custom_fields['field_phone'] as $phone)
  {
  print $phone->value."&nbsp;";
  }
  }
  print "</b></p>";
}  
/*
if(!empty($node->advert['field_phones1'])||!empty($node->advert['field_phones2']))
{
print "Телефоны:".(isset($node->advert['field_phones1'])?"<b>".$node->advert['field_phones1']."</b>":"").' '.(isset($node->advert['field_phones2'])?"<b>".$node->advert['field_phones2']."</b>":"");
}
*/
if(!empty($node->advert['field_address']))
{
print '<p>Адресс: <b>'.$node->advert['field_address'].'</b></p>';
}
if(!empty($node->advert['field_www']))
{
print '<p>Сайт: <b><a href="'.$node->advert['field_www'].'" target="_blank" rel="nofollow">'.$node->advert['field_www'].'</a></b></p>';
}
if(!empty($node->advert['field_social']))
{
print '<p>Социальные сети: <b><a href="'.$node->advert['field_social'].'" target="_blank" rel="nofollow">'.$node->advert['field_social'].'</a></b></p>';
}
if(!empty($node->advert['field_email']))
{
print '<p>Email: <b><a href="mailto:'.$node->advert['field_email'].'" rel="nofollow">'.$node->advert['field_email'].'</a></b></p>';
}
  ?>
  </td></tr>
</table>
<!--content eof-->
<!--/TD></TR>
</TABLE-->
<?php if (!empty($content['field_tags']) || !empty($content['links'])): ?>
  
<footer>
      <?php# print render($content['field_tags']); ?>
      <?php# print render($content['links']); ?>
    </footer>
    <?php endif; ?>
    <?php print render($content['comments']); ?>
	<?php
	if(!in_array(date('Y-m-d'),$node->public_dates))
		{
		print '<div class="overdue">объявление не актуально</div>';
		}
	?>
<? else:
### HERE TEMPLATE OF ADVERTS ROWS IN TAXONOMY PAGES
?>
<div class="pin"><div class="advert_node">
<!--div class="advert_node_taxonomy"-->
<h3><?=l($node->title,'node/'.$node->nid,array('attributes'=>array('title'=>$node->body)));?></h3>
<!--p><?//date("d/m/Y",$node->created);?></p-->
<p><?=mb_substr($node->body,0,150);?></p>
</div></div>
<?

endif;?>
